﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using ControleRepresentante.Common;
using ControleRepresentante.Logic;
using ControleRepresentante.Logic.Models;
using WebSite.ViewModels.Fields;
using WebSite.ViewModels.IndexViewModels;

namespace WebSite.ViewModels.ViewModelExtensions.IndexViewModelExtensions
{
    public static class RelatorioVisitaJolitexIndexColums
    {
        public static Guid Ocorrencia = new Guid("0919d97b-c6c5-4b60-84ae-6b149b6bcf28");
    }

    public class RelatorioVisitaJolitexIndexViewModel : IIndexViewModelExtension
    {
        private readonly RelatorioVisitaJolitexOcorrencia? m_Ocorrencia;

        public RelatorioVisitaJolitexIndexViewModel(RelatorioVisitaJolitexOcorrencia? ocorrencia)
        {
            m_Ocorrencia = ocorrencia;
        }

        public IEnumerable<IField> GetSearchFields()
        {
            DropDownListField dropDownListField = new DropDownListField("Ocorrência", "ocorrencia")
                .AddEmpty(!m_Ocorrencia.HasValue);

            foreach (RelatorioVisitaJolitexOcorrencia ocorrencia in Enum.GetValues(typeof(RelatorioVisitaJolitexOcorrencia)))
            {
                dropDownListField.Add(ocorrencia.GetDescription(), ocorrencia, ocorrencia == m_Ocorrencia);
            }

            yield return dropDownListField;
        }

        public bool CanEditSpecific(ModelBase modelBase)
        {
            return true;
        }

        public bool CanDeleteSpecific(ModelBase modelBase)
        {
            return true;
        }

        public void RegisterColumns(IndexColumnDefinitionsCollection indexColumnDefinitionsCollection, IIndexColumnsProvider indexColumnsProvider)
        {
            indexColumnDefinitionsCollection.Register(indexColumnsProvider[RelatorioVisitaJolitexIndexColums.Ocorrencia], x => ((RelatorioVisita)x).RelatorioVisitaJolitex.Ocorrencia.GetDescription());
        }

        public IEnumerable<TabItem> GetTabs(HtmlHelper htmlHelper)
        {
            return new TabItem[0];
        }
    }
}